home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / 3dvect39 / font.asm < prev    next >
Encoding:
Assembly Source File  |  1994-10-30  |  12.9 KB  |  502 lines

  1. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2. ;
  3. ; Filename     : font.asm
  4. ; Included from: Main assembley module
  5. ; Description  : Font and cosmetic screen handling routines.
  6. ;                This basically draws backgound screens/opening menus.
  7. ;                Have you played Red Baron or Aces of the Pacific?  It's
  8. ;                kind of like that.
  9. ;
  10. ; Written by: John McCarthy
  11. ;             1316 Redwood Lane
  12. ;             Pickering, Ontario.
  13. ;             Canada, Earth, Milky Way (for those out-of-towners)
  14. ;             L1X 1C5
  15. ;
  16. ; Internet/Usenet:  BRIAN.MCCARTHY@CANREM.COM
  17. ;         Fidonet:  Brian McCarthy 1:229/15
  18. ;   RIME/Relaynet: ->CRS
  19. ;
  20. ; Home phone, (905) 831-1944, don't call at 2 am eh!
  21. ;
  22. ; Send me your protected mode source code!
  23. ; Send me your Objects!
  24. ; But most of all, Send me a postcard!!!!
  25. ;
  26. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  27.  
  28.          .386p
  29.          jumps
  30.  
  31. code32   segment para public use32
  32.          assume cs:code32, ds:code32, ss:code32
  33.  
  34.          include pmode.ext                  ; include externals for other modules
  35.          include xmode.ext                  ; just in case we ever want to use them...
  36.          include macros.inc
  37.          include 3d.ext
  38.          include equ.inc
  39.  
  40.          public _fnt_tstring
  41.          public _fnt_string
  42.          public _initfont
  43.  
  44.          public _put_at_top
  45.          public _number_eax
  46.  
  47. newtext   equ -1
  48. border    equ -2
  49. fillarea  equ -3
  50. hole      equ -4
  51. lowercase equ -5
  52. uppercase equ -6
  53. steelbox  equ -7
  54. repeatbit equ -8
  55. textend   equ 0
  56.  
  57. wcase    db 0                               ; upper/lower case add
  58. colt     dw 0
  59. linecol  dw 0
  60. tw1      dw 0
  61. tq2      dw 0
  62. sinewave dw 0                               ; sine wave for colour
  63. ltflag   dw 0
  64. brflag   dw 0
  65. q1       dw 0
  66. w1       dw 0
  67. q2       dw 0
  68. w2       dw 0
  69. fontlen  dd 0                               ; offset to font length table
  70.  
  71. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  72. ; _fnt_tstring: Display _fnt_string of font from [esi] to zero byte on both video pages
  73. ; In:
  74. ;    ESI - offset of _fnt_string to display
  75. ; Out:
  76. ;    ?
  77. ;
  78. ; eg db -1
  79. ;    dw x,y
  80. ;    db colour,"Hello",0
  81. ;
  82. ; commands:  -1 start new x,y,colour and text
  83. ;            -2 draw full border starting at x,y to x,y colour offset col
  84. ;            -3 fill within limits x,y  to x,y  colour offset col
  85. ;            -4 draw inside border from x,y to x,y colour offset col
  86. ;            -5 set lower case
  87. ;            -6 set upper case
  88. ;            -7 steel textured box
  89. ;            -8 repeated _bitmap box
  90. ;
  91. ; Fill inside full borders 3 smaller than border
  92. ; Fill inside full borders 2 smaller than border to make a "lump"
  93. ; Fill inside "hole" border 2 smaller than hole
  94. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  95.  
  96. _fnt_tstring:
  97.          push esi                           ; same as _fnt_string, but does
  98.          call _fnt_string                   ; it to both sides
  99.          call _flip_page
  100.          pop esi
  101.          call _fnt_string
  102.          call _flip_page
  103.          ret
  104.  
  105. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  106. ; _fnt_string: Display _fnt_string of font from [esi] to zero byte on current video page
  107. ; In:
  108. ;    ESI - offset of _fnt_string to display
  109. ; Out:
  110. ;    ?
  111. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  112.  
  113. _fnt_string:
  114.          mov wcase,0                        ; default to upper case
  115.  
  116.          cld
  117.          lodsb
  118.          jmp testcommand
  119. freshtext:
  120.          lodsw
  121.          mov bx,ax                          ; x
  122.          lodsw
  123.          mov cx,ax                          ; y
  124.          mov ah,0
  125.          lodsb
  126.          mov dx,ax                          ; colour
  127. textloop:
  128.          lodsb                              ; get character/command
  129. testcommand:
  130.          cmp al,0
  131.          je txnon
  132.  
  133.          cmp al,newtext                     ; -1 = 255 = set new x,y,col
  134.          je freshtext
  135.  
  136.          cmp al,border                      ; -2 = outside border
  137.          jne n254
  138.          call outside
  139.          jmp textloop                       ; ok, i should've used indirect jumps
  140. n254:
  141.          cmp al,fillarea                    ; fine, give me a hassle, like i need it!
  142.          jne n253                           ; the code is done, i don't want to
  143.          call dofill                        ; change it all now so there!
  144.          jmp textloop
  145. n253:
  146.          cmp al,hole
  147.          jne n252
  148.          call inside
  149.          jmp textloop
  150. n252:
  151.          cmp al,lowercase
  152.          jne n251
  153.          mov wcase,128
  154.          jmp textloop
  155. n251:
  156.          cmp al,uppercase
  157.          jne n250
  158.          mov wcase,0
  159.          jmp textloop
  160. n250:
  161.          cmp al,steelbox
  162.          jne n249
  163.          call steeltext
  164.          jmp textloop
  165. n249:
  166.          cmp al,repeatbit
  167.          jne n248
  168.          call do_bitmapthingy
  169.          jmp textloop
  170. n248:
  171.          add al,wcase                       ; include which case
  172.          pusha
  173.          char ax,bx,cx,dx
  174.          popa
  175.          movzx edi,ax
  176.          add di,di
  177.          add edi,fontlen
  178.          add bx,[edi]                       ; inc to next position
  179.  
  180.          jmp textloop
  181. txnon:
  182.          ret
  183.  
  184. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  185. ; _initfont: Initilize upper and lower case fonts to be used with xmode font stuff
  186. ; In:
  187. ;   ESI -> lowercase font
  188. ;   EDI -> uppercase font
  189. ;   EBP -> font length tables
  190. ; Out:
  191. ;   ?
  192. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  193. _initfont:
  194.          mov fontlen,ebp
  195.  
  196.          push esi
  197.          push edi
  198.          pushw 0                            ; initialize _font0 block
  199.          call _set_display_font
  200.  
  201.          pushw 1                            ; initialize _font1 block
  202.          call _set_display_font
  203.  
  204.          ret
  205.  
  206. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  207. ;
  208. ; Here is the implementation of some of those cheap font "commands"
  209. ;
  210. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  211.  
  212. borderd  equ 2
  213. borderm  equ 9
  214. borderl  equ 15
  215.  
  216. outside:
  217.          lodsw                              ; draw outside box, get q1,w1  q2,w2
  218.          mov q1,ax                          ; q1,w1 is top left, q2,w2 is bot right
  219.          lodsw
  220.          mov w1,ax
  221.          lodsw
  222.          mov q2,ax
  223.          lodsw
  224.          mov w2,ax
  225.          lodsw
  226.          mov colt,ax
  227.  
  228.          push esi
  229.  
  230.          mov ax,colt
  231.          add ax,borderd+1
  232.          mov linecol,ax
  233.          drawline q1,w1,q1,w2,linecol       ; now draw lines, use macros
  234.          mov ax,colt
  235.          add ax,borderm-1
  236.          mov linecol,ax
  237.          drawline q1,w1,q2,w1,linecol
  238.          mov ax,colt
  239.          add ax,borderm+1
  240.          mov linecol,ax
  241.          drawline q2,w1,q2,w2,linecol
  242.          mov ax,colt
  243.          add ax,borderd+0
  244.          mov linecol,ax
  245.          drawline q1,w2,q2,w2,linecol
  246.  
  247.          inc w1                             ; bump for middle lines
  248.          dec w2
  249.          inc q1
  250.          dec q2
  251.  
  252.          mov ax,colt                        ; draw middle lines
  253.          add ax,borderl-1
  254.          mov linecol,ax
  255.          drawline q1,w1,q1,w2,linecol
  256.          mov ax,colt
  257.          add ax,borderl-2
  258.          mov linecol,ax
  259.          drawline q1,w1,q2,w1,linecol
  260.          mov ax,colt
  261.          add ax,borderl-2
  262.          mov linecol,ax
  263.          drawline q2,w1,q2,w2,linecol
  264.          mov ax,colt
  265.          add ax,borderm-1
  266.          mov linecol,ax
  267.          drawline q1,w2,q2,w2,linecol
  268.  
  269.          inc w1                             ; bump for inside lines
  270.          dec w2
  271.          inc q1
  272.          dec q2
  273.  
  274.          mov ax,colt
  275.          add ax,borderd+2
  276.          mov linecol,ax
  277.          drawline q1,w1,q1,w2,linecol       ; draw inner lines
  278.          mov ax,colt
  279.          add ax,borderd+1
  280.          mov linecol,ax
  281.          drawline q1,w1,q2,w1,linecol
  282.          mov ax,colt
  283.          add ax,borderd+0
  284.          mov linecol,ax
  285.          drawline q2,w1,q2,w2,linecol
  286.          mov ax,colt
  287.          add ax,borderl-2
  288.          mov linecol,ax
  289.          drawline q1,w2,q2,w2,linecol
  290.  
  291.          pop esi
  292.          ret
  293.  
  294. dofill:
  295.          lodsw                              ; fill box, get q1,w1  q2,w2
  296.          mov q1,ax                          ; q1,w1 is top left, q2,w2 is bot right
  297.          lodsw
  298.          mov w1,ax
  299.          lodsw
  300.          mov q2,ax
  301.          lodsw
  302.          mov w2,ax
  303.          lodsw
  304.          mov colt,ax
  305.  
  306.          push esi
  307.          block q1,w1,q2,w2,colt
  308.          pop esi
  309.  
  310.          ret
  311.  
  312. inside:
  313.          lodsw                              ; draw inside box, get q1,w1  q2,w2
  314.          mov q1,ax                          ; q1,w1 is top left, q2,w2 is bot right
  315.          lodsw
  316.          mov w1,ax
  317.          lodsw
  318.          mov q2,ax
  319.          lodsw
  320.          mov w2,ax
  321.          lodsw
  322.          mov colt,ax
  323.  
  324.          push esi
  325.  
  326.          mov ax,colt
  327.          add ax,borderm+1
  328.          mov linecol,ax
  329.          drawline q1,w1,q1,w2,linecol       ; now draw lines, use macros
  330.          mov ax,colt
  331.          add ax,borderd-1
  332.          mov linecol,ax
  333.          drawline q1,w1,q2,w1,linecol
  334.          mov ax,colt
  335.          add ax,borderd+1
  336.          mov linecol,ax
  337.          drawline q2,w1,q2,w2,linecol
  338.          mov ax,colt
  339.          add ax,borderm+2
  340.          mov linecol,ax
  341.          drawline q1,w2,q2,w2,linecol
  342.  
  343.          inc w1                             ; bump for inside lines
  344.          dec w2
  345.          inc q1
  346.          dec q2
  347.  
  348.          mov ax,colt
  349.          add ax,borderm+3
  350.          mov linecol,ax
  351.          drawline q1,w1,q1,w2,linecol       ; now draw lines, use macros
  352.          mov ax,colt
  353.          add ax,borderd+1
  354.          mov linecol,ax
  355.          drawline q1,w1,q2,w1,linecol
  356.          mov ax,colt
  357.          add ax,borderd+2
  358.          mov linecol,ax
  359.          drawline q2,w1,q2,w2,linecol
  360.          mov ax,colt
  361.          add ax,borderl
  362.          mov linecol,ax
  363.          drawline q1,w2,q2,w2,linecol
  364.  
  365.          pop esi
  366.          ret
  367.  
  368. simplesine dw 9,10,11,12,13,14,15,15
  369.          dw 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8
  370.  
  371. steeltext:
  372.          mov ltflag,0                       ; make steel textured box (sin wave)
  373.          mov brflag,0
  374.          mov sinewave,0
  375.  
  376.          lodsw
  377.          mov q1,ax
  378.          mov q2,ax
  379.          lodsw
  380.          mov tw1,ax
  381.          lodsw
  382.          mov tq2,ax
  383.          lodsw
  384.          mov w1,ax
  385.          mov w2,ax
  386.          lodsw
  387.          mov linecol,ax
  388.          lodsw
  389.          mov colt,ax
  390. steel_loop:
  391.          mov cx,colt
  392.          add sinewave,cx
  393.          movzx edi,sinewave
  394.          shr di,8
  395.          and di,32*2-2
  396.          mov ax,simplesine[edi]
  397.          add ax,linecol
  398.          mov di,ax
  399.  
  400.          drawline q1,w1,q2,w2,di
  401.  
  402.          mov ax,ltflag
  403.          cmp ax,0
  404.          jne st_doside
  405.  
  406.          dec w1
  407.          mov ax,w1
  408.          cmp ax,tw1
  409.          jne st_dopt2
  410.  
  411.          mov ltflag,1
  412.          jmp st_dopt2
  413. st_doside:
  414.          inc q1
  415. st_dopt2:
  416.          mov ax,brflag
  417.          cmp ax,1
  418.          je st_doup
  419.  
  420.          inc q2
  421.          mov ax,q2
  422.          cmp ax,tq2
  423.          jne st_chkout
  424.  
  425.          mov brflag,1
  426. st_chkout:
  427.          mov ax,q1
  428.          cmp ax,tq2
  429.          jna steel_loop
  430.  
  431.          ret
  432. st_doup:
  433.          dec w2
  434.          jmp st_chkout
  435.  
  436. do_bitmapthingy:
  437.          push esi
  438.          lodsd                              ; do repeat _bitmap
  439.          push eax                           ; push _bitmap offset (location of _bitmap)
  440.          lodsw                              ; get _x1,_y1,_x2,_y2
  441.          push ax
  442.          lodsw
  443.          push ax
  444.          lodsw
  445.          push ax
  446.          lodsw
  447.          push ax
  448.          call _repeat_bitmap
  449.  
  450.          pop esi
  451.          add esi,2+2+2+2+4                  ; add for next text instruction
  452.  
  453.          ret
  454.  
  455. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  456. ; _put_at_top: Debugging Tool
  457. ;  In:
  458. ;    Regs - null
  459. ;    _number_eax - number to plot at top of screen
  460. ;  Out = In
  461. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  462.  
  463. _number_eax dd 0
  464.  
  465. hexs     db "0123456789ABCDEF"
  466.  
  467. top_number db -3
  468.          dw 100,12,220,32,3
  469.          db -1
  470.          dw 107,20
  471.          db 13
  472.          db "EAX="
  473. number   db "00000000",0
  474.  
  475. _put_at_top:
  476.          pushad
  477.          mov eax,_number_eax
  478.          mov esi,7
  479.          call set_hex
  480.          call set_hex
  481.          call set_hex
  482.          call set_hex
  483.          call set_hex
  484.          call set_hex
  485.          call set_hex
  486.          call set_hex
  487.          mov esi, o top_number
  488.          call _fnt_string
  489.          popad
  490.          ret
  491. set_hex:
  492.          mov di,ax
  493.          and edi,0fh
  494.          mov bl,hexs[edi]
  495.          mov number[esi],bl
  496.          shr eax,4
  497.          dec si
  498.          ret
  499.  
  500. code32   ends
  501.          end
  502.